﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    public class OwnDAL
    {
        SQLHelper SQLHelper = null;
        QXHelper QXHelper = null;
        public OwnDAL()
        {
            SQLHelper = new SQLHelper();
            QXHelper = new QXHelper();
        }

        //start记事本部分
        #region 查询记事本
        public string jhy_note_query(string note_para, string laypage, string laylimit)
        {
            DataSet ds = new DataSet();
            string proc = "jhy_note_query";
            SqlParameter[] spa = new SqlParameter[] {
                new SqlParameter("@note_para",note_para),
                new SqlParameter("@laypage",laypage),
                new SqlParameter("@laylimit",laylimit)
            };
            ds = SQLHelper.ExecuteQueryDataSet(proc, spa, CommandType.StoredProcedure);
            return QXHelper.LayuiTablePageJson(ds);
        }
        #endregion
        #region 记事本添加内容
        public bool jhy_note_add(string note_title, string note_content)
        {
            bool flag = false;
            string proc = "jhy_note_add";
            SqlParameter[] spa = new SqlParameter[] {
                new SqlParameter("@note_title",note_title),
                new SqlParameter("@note_content",note_content)
            };
            int res = SQLHelper.ExecuteNonQuery(proc, spa, CommandType.StoredProcedure);
            if (res > 0)
            {
                flag = true;
            }
            return flag;
        }
        #endregion
        #region 记事本修改内容
        public bool jhy_note_edit(string note_id, string note_title, string note_content)
        {
            bool flag = false;
            string proc = "jhy_note_edit";
            SqlParameter[] spa = new SqlParameter[] {
                new SqlParameter("@note_id",note_id),
                new SqlParameter("@note_title",note_title),
                new SqlParameter("@note_content",note_content)
            };
            int res = SQLHelper.ExecuteNonQuery(proc, spa, CommandType.StoredProcedure);
            if (res > 0)
            {
                flag = true;
            }
            return flag;
        }
        #endregion
        #region 记事本删除内容
        public bool jhy_note_delete(string note_id)
        {
            bool flag = false;
            string proc = "jhy_note_delete";
            SqlParameter[] spa = new SqlParameter[] {
                new SqlParameter("@note_id",note_id)
            };
            int res = SQLHelper.ExecuteNonQuery(proc, spa, CommandType.StoredProcedure);
            if (res > 0)
            {
                flag = true;
            }
            return flag;
        }
        #endregion
        //end 记事本部分

        //start 代办任务
        #region 查询代办任务
        public string jhy_task_query()
        {
            DataTable dt = new DataTable();
            string proc = "jhy_task_query";
            dt = SQLHelper.ExecuteQuery(proc, CommandType.StoredProcedure);
            return QXHelper.LayuiTableJson(dt);
        }
        #endregion
        #region 查询已完成代办任务
        public string jhy_task_query_done(string laypage, string laylimit)
        {
            DataSet ds = new DataSet();
            string proc = "jhy_task_query_done";
            SqlParameter[] spa = new SqlParameter[] {
                new SqlParameter("@laypage",laypage),
                new SqlParameter("@laylimit",laylimit)
            };
            ds = SQLHelper.ExecuteQueryDataSet(proc, spa, CommandType.StoredProcedure);
            return QXHelper.LayuiTablePageJson(ds);
        }
        #endregion
        #region 添加代办任务
        public bool jhy_task_add(string task_content, string task_datetime)
        {
            bool flag = false;
            string proc = "jhy_task_add";
            SqlParameter[] spa = new SqlParameter[] {
                new SqlParameter("@task_content",task_content),
                new SqlParameter("@task_datetime",task_datetime)
            };
            int res = SQLHelper.ExecuteNonQuery(proc, spa, CommandType.StoredProcedure);
            if (res > 0)
            {
                flag = true;
            }
            return flag;
        }
        #endregion
        #region 删除代办任务
        public bool jhy_task_delete(string task_id)
        {
            bool flag = false;
            string proc = "jhy_task_delete";
            SqlParameter[] spa = new SqlParameter[] {
                new SqlParameter("@task_id",task_id)
            };
            int res = SQLHelper.ExecuteNonQuery(proc, spa, CommandType.StoredProcedure);
            if (res > 0)
            {
                flag = true;
            }
            return flag;
        }
        #endregion
        #region 修改代办任务
        public bool jhy_task_edit(string task_id,string task_content, string task_datetime)
        {
            bool flag = false;
            string proc = "jhy_task_edit";
            SqlParameter[] spa = new SqlParameter[] {
                new SqlParameter("@task_id",task_id),
                new SqlParameter("@task_content",task_content),
                new SqlParameter("@task_datetime",task_datetime)
            };
            int res = SQLHelper.ExecuteNonQuery(proc, spa, CommandType.StoredProcedure);
            if (res > 0)
            {
                flag = true;
            }
            return flag;
        }
        #endregion
        #region 修改代办任务状态
        public bool jhy_task_done(string task_id)
        {
            bool flag = false;
            string proc = "jhy_task_done";
            SqlParameter[] spa = new SqlParameter[] {
                new SqlParameter("@task_id",task_id)
            };
            int res = SQLHelper.ExecuteNonQuery(proc, spa, CommandType.StoredProcedure);
            if (res > 0)
            {
                flag = true;
            }
            return flag;
        }
        #endregion
        //end 代办任务

        //start 日记本
        #region 查询日记
        public string jhy_diary_query(string date_start, string date_end,string para)
        {
            DataTable dt = new DataTable();
            string proc = "jhy_diary_query";
            SqlParameter[] spa = new SqlParameter[] {
                new SqlParameter("@date_start",date_start),
                new SqlParameter("@date_end",date_end),
                new SqlParameter("@para",para)
            };
            dt = SQLHelper.ExecuteQuery(proc,spa, CommandType.StoredProcedure);
            return QXHelper.TableToJson(dt);
        }
        #endregion
        #region 添加日记
        public bool jhy_diary_add(string diary_html, string diary_txt)
        {
            bool flag = false;
            string proc = "jhy_diary_add";
            SqlParameter[] spa = new SqlParameter[] {
                new SqlParameter("@diary_html",diary_html),
                new SqlParameter("@diary_txt",diary_txt)
            };
            int res = SQLHelper.ExecuteNonQuery(proc, spa, CommandType.StoredProcedure);
            if (res > 0)
            {
                flag = true;
            }
            return flag;
        }
        #endregion
        #region 修改日记
        public bool jhy_diary_edit(string diary_id,string diary_html, string diary_txt)
        {
            bool flag = false;
            string proc = "jhy_diary_edit";
            SqlParameter[] spa = new SqlParameter[] {
                new SqlParameter("@diary_id",diary_id),
                new SqlParameter("@diary_html",diary_html),
                new SqlParameter("@diary_txt",diary_txt)
            };
            int res = SQLHelper.ExecuteNonQuery(proc, spa, CommandType.StoredProcedure);
            if (res > 0)
            {
                flag = true;
            }
            return flag;
        }
        #endregion
        #region 删除日记
        public bool jhy_diary_delete(string diary_id)
        {
            bool flag = false;
            string proc = "jhy_diary_delete";
            SqlParameter[] spa = new SqlParameter[] {
                new SqlParameter("@diary_id",diary_id)
            };
            int res = SQLHelper.ExecuteNonQuery(proc, spa, CommandType.StoredProcedure);
            if (res > 0)
            {
                flag = true;
            }
            return flag;
        }
        #endregion
        //end 日记本

    }
}
